import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/Login.vue')
  },
  {
    path: '/',
    // name: 'Layout', 如果父路由有默认子路由 那么 name 没有意义
    component: () => import('@/views/layout/Layout.vue'),
    children: [
      {
        path: '', // 默认子路由
        name: 'Home',
        component: () => import('@/views/home/Home.vue')
      },
      {
        path: '/qa',
        name: 'Question',
        component: () => import('@/views/qa/Question.vue')
      },
      {
        path: '/video',
        name: 'Video',
        component: () => import('@/views/video/Video.vue')
      },
      {
        path: '/my',
        name: 'My',
        component: () => import('@/views/my/My.vue')
      }
    ]
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('@/views/search/Search.vue')
  },
  {
    path: '/article/:articleId',
    name: 'Article',
    component: () => import('@/views/article/ArticleDetails.vue'),
    props: true
  },
  {
    path: '/user/profile',
    name: 'UserProfile',
    component: () => import('@/views/userprofile/user-profile.vue')

  }
]

const router = new VueRouter({
  routes
})

export default router
